a = []
a2 = 0
z = 0
x = 0
v = 0
for i in range(100,1000):
    for y in range(2,i):
        if i%y==0:
            break
    else:
        a.append(i)
s = input().split()
for z in range(len(s)):
    if s[0] == "zero":
        z = 0
    if s[0] == "one":
        z = 1
    if s[0] == "two":
        z = 2
    if s[0] == "three":
        z = 3
    if s[0] == "four":
        z = 4
    if s[0] == "five":
        z = 5
    if s[0] == "six":
        z = 6
    if s[0] == "seven":
        z = 7
    if s[0] == "eight":
        z = 8
    if s[0] == "nine":
        z = 9

    if s[1] == "zero":
        x = 0
    if s[1] == "one":
        x = 1
    if s[1] == "two":
        x = 2
    if s[1] == "three":
        x = 3
    if s[1] == "four":
        x = 4
    if s[1] == "five":
        x = 5
    if s[1] == "six":
        x = 6
    if s[1] == "seven":
        x = 7
    if s[1] == "eight":
        x = 8
    if s[1] == "nine":
        x = 9

    if s[2] == "zero":
        v = 0
    if s[2] == "one":
        v = 1
    if s[2] == "two":
        v = 2
    if s[2] == "three":
        v = 3
    if s[2] == "four":
        v = 4
    if s[2] == "five":
        v = 5
    if s[2] == "six":
        v = 6
    if s[2] == "seven":
        v = 7
    if s[2] == "eight":
        v = 8
    if s[2] == "nine":
        s2 = 9
a2 = z*100+x*10+v
if a2 in a:
    print(a2)
else:
    for i in range(len(a)):
        if a[i]>a2:
            print(a[i])
            break
